package com.me.mygdxgame.renderer;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.badlogic.gdx.Gdx;

public class ContextManager
{
	
	private static final String TAG = ContextManager.class.getSimpleName();
	List<Context> contexts = new ArrayList<Context>();

	private static ContextManager instance = null;

	private ContextManager()
	{

	}

	public static ContextManager getInstance()
	{
		if (instance == null)
		{
			instance = new ContextManager();
		}

		return instance;
	}

	public void addContext(Context context)
	{
		Gdx.app.log(TAG, "Adding context");
		contexts.add(context);
	}

	public void removeContext(Context context)
	{
		Gdx.app.log(TAG, "Removing context");
		contexts.remove(context);
	}
	
	@SuppressWarnings("rawtypes")
	public void render(float dt)
	{
		Iterator it = contexts.iterator();
		
		while(it.hasNext())
		{
			Context temp = (Context) it.next();
			temp.renderContext();
		}
	}

}
